package com.ludomancy.sos64.components;

import java.awt.Graphics;
import java.awt.Point;

import com.ludomancy.gamelib.ImageAnimation;
import com.ludomancy.gamelib.ImageStrip;
import com.ludomancy.gamelib.ResourceManager;
import com.ludomancy.sos64.Component;
import com.ludomancy.sos64.Game;

public class Food extends Component
{
	private ImageAnimation food;
	
	public Food(Point pos)
	{
		super(pos.x,pos.y);
		if(food == null)
		{
			food = new ImageAnimation(new ImageStrip(ResourceManager.getImage("food.png"), 21, 18), 4);
		}
	}
	
	public Point getSize()
	{
		return new Point(21,18);
	}
	
	public boolean isOrganic()
	{
		return true;
	}
	
	public void onCollided(Component other)
	{
		if(other instanceof Larva64)
		{
			// feed the larva!
			Larva64 larva = (Larva64)other;
			larva.feed();
			Game.game.components.remove(this);
		}
	}

	public void paint(Graphics g, int px, int py)
	{
		food.paintCurrentFrame(g, px, py);
	}
	
	public void update()
	{
		food.update();
	}
}
